import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'tool.dart';

extension IntExtension on int {
  double adapt() {
    BuildContext? context = NavKey.getCurrentContext();
    if (context == null) {
      return toDouble();
    }else {
      Size size = MediaQuery.of(context!).size;
      return (size.width / 375 * this).floor().toDouble();
    }

  }
}
extension IntToColor on int {
  Color toColor() {
    final str = toRadixString(16);
    final num = int.parse(str, radix: 16);
    return Color(num + 0xFF000000);
  }
}
extension StringToColor on String {
  Color toColor() {
    if (length < 7 || !startsWith("#")) {
      return Colors.blueAccent;
    }
    return Color(int.parse(substring(1,7), radix: 16) & 0xFF000000);

  }
}





